//
//  remainingTaskGV.swift
//  demo01
//
//  Created by babybus on 2025/7/7.
//
import Foundation
import UIKit
import SnapKit
import Alamofire

class RemainingTaskGVView:UIView{
    //全局变量
    public var remainingTask:UILabel = UILabel()
    public var reaminingNum:Int = 9
    private let taskLabel:UILabel = UILabel()
    
    private var img:UIImageView = UIImageView(image: UIImage(named: "remainingTask.png"))
    
    private var promptView:UIView = UIView()
    
    //初始化方法
    override init(frame: CGRect) {
        super.init(frame: frame)
        attributeInit()
        setupUI()
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    func attributeInit(){
        
    }
    func setupUI(){
        remainingTask.font = UIFont.systemFont(ofSize: 14)
        remainingTask.adjustsFontSizeToFitWidth = true
        remainingTask.minimumScaleFactor = 0.25
        
        if reaminingNum>9 {
            taskLabel.text = "可选以下任意任务做9个/9次"
        }else{
            taskLabel.text = "可选以下任意任务做" + String(reaminingNum) + "个/9次"
        }
        taskLabel.font = UIFont.systemFont(ofSize: 13)
        taskLabel.adjustsFontSizeToFitWidth = true
        taskLabel.minimumScaleFactor = 0.25
        taskLabel.textColor = UIColor.systemGray
        
        promptView.addSubview(img)
        promptView.addSubview(remainingTask)
        self.addSubview(promptView)
        self.addSubview(taskLabel)
        
        img.snp.makeConstraints { make in
            make.width.height.equalToSuperview()
        }
        remainingTask.snp.makeConstraints { make in
            make.centerY.equalToSuperview()
            make.width.equalTo(255)
            make.height.equalTo(20)
            make.left.equalTo(44)
        }
        promptView.snp.makeConstraints { make in
            make.width.equalTo(327)
            make.height.equalTo(36)
            make.top.equalToSuperview()
        }
        taskLabel.snp.makeConstraints { make in
            make.width.equalTo(166)
            make.height.equalTo(16)
            make.top.equalTo(promptView.snp.bottom).offset(12)
            make.left.equalToSuperview()
        }
        
    }
}

